import axios from 'axios';

//登录
export const login = (data) => {
    return axios.post('/admin/v1.0/user/login', data);
};
//退出登录
export const loginout = () => {
    return axios.get('/admin/v1.0/user/auth/logout');
};
//用户注册
export const regUser = (data) => {
    return axios.post('/admin/v1.0/user/login', data);
};
//修改密码 oldPwd   newPWd
export const getuserMenu = (data) => {
    return axios.get('/admin/v1.0/user/auth/userMenu?parentId=' + data);
};
//菜单获取
export const updatePwd = (data) => {
    return axios.post('/admin/v1.0/user/auth/updatepassword', data);
};
//----------------------------------------------------------------------------------------------
// 产品列表
export const goodsList = (data) => {
    return axios.post('/admin/v1.0/auth/goods/list', data);
};
// 增加产品
export const addGoods = (data) => {
    return axios.post('/admin/v1.0/auth/goods/add', data);
};
// 产品详情
export const goodsDetail = (data) => {
    return axios.get('/admin/v1.0/auth/goods/detail?id=' + data);
};
// 修改产品
export const updateGoods = (data) => {
    return axios.post('/admin/v1.0/auth/goods/update', data);
};
// 增加产品价格
export const addPrice = (data) => {
    return axios.post('/admin/v1.0/auth/goods/price/add', data);
};
export const updatePriceList = (data) => {
    return axios.post('/admin/v1.0/auth/goods/price/list/update', data);
};
// 产品价格详情
export const detailsPrice = (data) => {
    return axios.get('/admin/v1.0/auth/goods/price/details?id=' + data);
};
// 产品价格列表
export const listPrice = (data) => {
    return axios.post('/admin/v1.0/auth/goods/price/list', data);
};
// 修改产品价格
export const updatePrice = (data) => {
    return axios.post('/admin/v1.0/auth/goods/price/update', data);
};
//分销商下拉
export const distributorslist = (data) => {
    return axios.post('/admin/v1.0/auth/goods/dropdown', data);
};
// /admin/v1.0/auth/goods/dropdown/viwe
export const dropdownViwe = (data) => {
    return axios.post('/admin/v1.0/auth/goods/dropdown/viwe', data);
};
//------------------------------------------------------------------------------------------------

//订单列表
export const orderList = (data) => {
    return axios.post('/admin/v1.0/auth/order/list', data);
};
//订单详情
export const orderDetail = (data) => {
    return axios.get('/admin/v1.0/auth/order/details?id=' + data);
};
//订单改为已发货
export const orderDelivered = (data) => {
    return axios.post('/admin/v1.0/auth/order/orderDelivered', data);
};
//审核失败修改退款单
export const updateApplyFailRefund = (data) => {
    return axios.post('/admin/v1.0/auth/order/refund/apply/fail/update', data);
};
//申请退货成功
export const updateApplySuccessRefund = (data) => {
    return axios.post('/admin/v1.0/auth/order/refund/apply/success/update', data);
};
//收到退货快递过后执行退款
export const refundUserPrice = (data) => {
    return axios.post('/admin/v1.0/auth/order/refund/price', data);
};
/**
 * 封装导出Excal文件请求
 * @param url
 * @param data
 * @returns {Promise}
 */
export function exportExcel(options = {}) {
    return new Promise((resolve, reject) => {
        axios.defaults.headers['content-type'] = 'application/json;charset=UTF-8';
        axios({
            method: 'post',
            url: "/admin/v1.0/auth/order/down", // 请求地址
            data: options, // 参数
            responseType: 'blob' // 表明返回服务器返回的数据类型
        }).then(
            response => {
                if (!response) {
                    return;
                }
                let url = window.URL.createObjectURL(new Blob([response]));
                let link = document.createElement('a');
                link.style.display = 'none';
                link.href = url;
                link.setAttribute('download', '订单数据.xlsx');

                document.body.appendChild(link);
                link.click();
            },
            err => {
                reject(err);
            }
        );
    });
}

// -----------------------------------------------------------------------------------------------
// 新闻列表
export const newsList = (data) => {
    return axios.post('/admin/v1.0/auth/news/list', data);
};
//新闻详情
export const newsDetails = (data) => {
    return axios.get('/admin/v1.0/auth/news/details?id=' + data);
};
// 增加新闻
export const newsAdd = (data) => {
    return axios.post('/admin/v1.0/auth/newslist/add', data);
};
// 修改新闻
export const newsUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/newslist/update', data);
};
// ----------------------------------------------------------------------------------------------
// 问卷列表
export const volumeList = (data) => {
    return axios.post('/admin/v1.0/auth/volume/list', data);
};
// 问卷详情
export const volumeDetails = (data) => {
    return axios.get('/admin/v1.0/auth/volume/details?id=' + data);
};
// 问卷修改
export const updateQuestion = (data) => {
    return axios.post('/admin/v1.0/auth/volume/update', data);
};
// 问卷 选择题修改
export const optionUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/volume/update/option', data);
};
// 问卷 选择题删除
export const optionDelete = (data) => {
    return axios.post('/admin/v1.0/auth/volume/delete/option?id=' + data);
};
// 问题遍历增加到版本
export const addPaper = (data) => {
    return axios.post('/admin/v1.0/auth/volume/add/paper', data);
};
// 添加问题
export const addQuestion = (data) => {
    return axios.post('/admin/v1.0/auth/volume/add/question', data);
};
//添加选择题 
export const addOption = (data) => {
    return axios.post('/admin/v1.0/auth/volume/add/option', data);
};
// 版本循环
export const listPaper = (data) => {
    return axios.post('/admin/v1.0/auth/volume/paper/list', data);
};
//版本下拉/paper/dropdown
export const dropDown = (data) => {
    return axios.post('/admin/v1.0/auth/volume/paper/dropdown', data);
};
// 用户
export const listAnswerUser = (data) => {
    return axios.post('/admin/v1.0/auth/volume/list/user', data);
};//根据用户  和  版本 查询 问题所有
export const answerDetails = (data) => {
    return axios.post('/admin/v1.0/auth/volume/answer/details', data);
};
// ---------------------------------------------------------------------------------------------
// 用户列表/admin/v1.0/auth/user/list
export const userList = (data) => {
    return axios.post('/admin/v1.0/auth/user/list', data);
};
// 用户修改（冻结功能）
export const userUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/user/update', data);
};
// 角色修改
export const updateRole = (data) => {
    return axios.post('/admin/v1.0/auth/user/updaterole', data);
};
export const adminList = (data) => {
    return axios.post('/admin/v1.0/auth/user/adminlist', data);
};
//用户详情 用于 超级管理 以及 首页 点击修改
export const userDetail = (data) => {
    return axios.get('/admin/v1.0/auth/user/detail?id='+data);
};
// ---------------------------------------------------------------------------------------------
// 分销商列表
export const farmList = (data) => {
    return axios.post('/admin/v1.0/auth/distributors/list', data);
};
export const farmAdd = (data) => {
    return axios.post('/admin/v1.0/auth/distributors/add', data);
};
export const farmUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/distributors/update', data);
};
export const farmDetails = (data) => {
    return axios.get('/admin/v1.0/auth/distributors/details?id=' + data);
};
//分类管理
export const cateList = (data) => {
    return axios.post('/admin/v1.0/auth/distributors/category/list', data);
};
//新增 一二级 分类 
export const framCategoryAdd = (data) => {
    return axios.post('/admin/v1.0/auth/distributors/add/category', data);
};
// ---------------------------------------------------------------------------------------------
// 权限管理
export const menuadd = (data) => {
    return axios.post('/admin/v1.0/auth/permission/menu/add', data);
};
export const permissionlist = (data) => {
    return axios.post('/admin/v1.0/auth/permission/all/list', data);
};
export const menuupdate = (data) => {
    return axios.post('/admin/v1.0/auth/permission/menu/update', data);
};
export const menudelete = (data) => {
    return axios.get('/admin/v1.0/auth/permission/menu/delete?menuId=' + data);
};
export const roleadd = (data) => {
    return axios.post('/admin/v1.0/auth/permission/role/add', data);
};
export const roleupdate = (data) => {
    return axios.post('/admin/v1.0/auth/permission/role/update', data);
};
export const rolelist = (data) => {
    return axios.post('/admin/v1.0/auth/permission/role/list', data);
};
export const checkmenu = (data) => {
    return axios.get('/admin/v1.0/auth/permission/rolepermission/list?roleId=' + data);
};
export const rolepermissionadd = (data) => {
    return axios.post('/admin/v1.0/auth/permission/rolepermission/add', data);
};
export const roledelete = (data) => {
    return axios.get('/admin/v1.0/auth/permission/role/delete?roleId=' + data);
};

// ------------------------------------------------------------------------------------------
// 系统类别 中的分类
// 一级
// export const categoryAdd = (data) => {
//     return axios.post('/sys/v1.0/auth/category/add', data);
// };
export const categoryAdd = (data) => {
    return axios.post('/admin/v1.0/auth/goods/category/add', data);
};
// 一级
export const categoryList = (data) => {
    return axios.post('/admin/v1.0/auth/goods/category/list',data);
};
//往下一级用不着
export const categoryDelete = (data) => {
    return axios.get('/admin/v1.0/auth/goods/category/delete?id='+data);
};
export const categoryUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/goods/category/update', data);
};
export const categoryDetail = (data) => {
    return axios.get('/admin/v1.0/auth/goods/category/detail?id=' + data);
};
//--------------------------------------------------日志管理--------------------------------------------
export const logsRequestAllList = (data) => {
    return axios.post('/admin/v1.0/auth/log/logsrequestall/list', data);
};
export const logsRequestAllDetail = (data) => {
    return axios.post('/admin/v1.0/auth/log/logsrequestall/detail?id=' + data);
};
//发布种植圈
export const circleList = (data) => {
    return axios.post('/admin/v1.0/auth/resourcecircle/list', data);
};
// ---------------------------------------------------------------------------------------------------
// 广告管理
export const advertisingList = (data) => {
    return axios.post('/admin/v1.0/auth/advertising/list', data);
};
export const advertisingDetails = (data) => {
    return axios.get('/admin/v1.0/auth/advertising/detail?id=' + data);
};
export const advertisingUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/advertising/update', data);
};
export const advertisingAdd = (data) => {
    return axios.post('/admin/v1.0/auth/advertising/add', data);
};
export const advertisingDelete = (data) => {
    return axios.get('/admin/v1.0/auth/advertising/delete?id=' + data);
};
// ------------------------------------------------------------------------
// 积分规则
export const integralList = (data) => {
    return axios.post('/admin/v1.0/auth/rule/list', data);
};
export const integralDetails = (data) => {
    return axios.get('/admin/v1.0/auth/rule/details?id=' + data);
};
export const integralAdd = (data) => {
    return axios.post('/admin/v1.0/auth/rule/add', data);
};
export const integralUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/rule/update', data);
};
// ----------------------------------------------------------------------
// 消息管理
export const messageList = (data) => {
    return axios.post('/admin/v1.0/auth/message/list', data);
};
export const messageAdd = (data) => {
    return axios.post('/admin/v1.0/auth/message/add', data);
};
export const userDown = (data) => {
    return axios.post('/admin/v1.0/auth/message/dropdown', data);
};
// ---------------------------------------------------------------------
// 优惠券管理
export const voucherList = (data) => {
    return axios.post('/admin/v1.0/auth/voucher/list', data);
};
export const voucherAdd = (data) => {
    return axios.post('/admin/v1.0/auth/voucher/add', data);
};
export const voucherUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/voucher/update', data);
};
export const voucherDetails = (data) => {
    return axios.get('/admin/v1.0/auth/voucher/details?id=' + data);
};
export const goodsDrop = (data) => {
    return axios.post('/admin/v1.0/auth/voucher/goods/drop', data);
};
// -------------------------------------------------------------------------
// 菜单(首页)管理
export const homePageList = (data) => {
    return axios.post('/admin/v1.0/auth/homepage/list', data);
};
export const homePageGoods = (data) => {
    return axios.get('/admin/v1.0/auth/homepage/details/goods?view=' + data);
};
export const addMenu = (data) => {
    return axios.post('/admin/v1.0/auth/homepage/add', data);
};
export const updateMenu = (data) => {
    return axios.post('/admin/v1.0/auth/homepage/update', data);
};
export const updateViwe = (data) => {
    return axios.post('/admin/v1.0/auth/homepage/update/viwe', data);
};

//卡号列表//卡号使用详情
export const cardnumberList = (data) => {
    return axios.post('/admin/v1.0/auth/order/cardnumber/list', data);
};
export const cardnumberDetails = (data) => {
    return axios.get('/admin/v1.0/auth/order/cardnumber/details?orderDetailId=' + data);
};
export const activationInformation = (data) => {
    return axios.get('/admin/v1.0/auth/order/cardnumber/information?cardNumber=' + data);
};
// 代理管理--
export const agentList = (data) => {
    return axios.post('/admin/v1.0/auth/agent/list', data);
};
export const agentDetails = (data) => {
    return axios.get('/admin/v1.0/auth/agent/details?id=' + data);
};
export const agentUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/agent/update', data);
};
export const agentGoodsList = (data) => {
    return axios.post('/admin/v1.0/auth/agent/goods/list', data);
};
export const agentOrderList = (data) => {
    return axios.post('/admin/v1.0/auth/agent/order/list', data);
};
export const sharebenefilsDetail = (data) => {
    return axios.get('/admin/v1.0/auth/agent/sharebenefils/detail?agentId=' + data);
};
export const sharebenefilsUpadate = (data) => {
    return axios.post('/admin/v1.0/auth/agent/sharebenefils/update', data);
};
//提现列表 -----------------------------------------
export const withdrawList = (data) => {
    return axios.post('/admin/v1.0/auth/user/withdraw/list', data);
};
export const withdrawUpdate = (data) => {
    return axios.post('/admin/v1.0/auth/user/withdraw/update', data);
};
export const withdrawDetails = (data) => {
    return axios.get('/admin/v1.0/auth/user/withdraw/details?id=' + data);
};
// -------------------------------------------------
//新增商品 需要的 下拉列表
export const listWithChildren = (data) => {
    return axios.post('/admin/v1.0/auth/goods/listWithChildren',data);
};
export const goodsCategoryList = (data) => {
    return axios.post('/admin/v1.0/auth/goods/category/list',data);
};

export const teahouseList = (data) => {
    return axios.post('/admin/v1.0/auth/teahouse/list',data);
};
// 茶楼
// 茶楼列表
export const teaHouseList = (data) =>{
    return axios.post('/admin/v1.0/floor/auth/teahouse/list',data)
};
// 修改茶楼
export const teaUpdate = (data) =>{
    return axios.post('/admin/v1.0/floor/auth/teahouse/update',data)
};
// 查询楼层
export const inquireFloor = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/floor/list?teahouseId="+data)
};
// 增加楼层
export const addFloor = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/floor/add",data)
};
//楼层修改
export const updateFloor = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/floor/update",data)
};
// 增加房间
export const addHouse = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/room/add",data)  
};
// 修改房间
export const updateHouse = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/room/update",data)
};
// 房间详情
export const houseDetail = (data) =>{
    return axios.post("/admin/v1.0/floor/auth/room/detail?roomId="+data)
}
//---
//预约接口
export const reserveList = (data) => {
    return axios.post('/admin/v1.0/floor/auth/reserve/list',data);
};
export const reserveUpdate = (data) => {
    return axios.post('/admin/v1.0/floor/auth/reserve/update',data);
};
